﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace HU8.Web.FileExplorer.FileExplorer.WebServices
{
    public class ConvertToPdf
    {
        public static bool Convert(string FlashPaperPath, string WaitConvertFilePath, string EndConvertFilePath)
        {
            bool Success = false;
            try
            {
                //创建一个进程  执行指令 
                //将
                System.Diagnostics.Process pss = new System.Diagnostics.Process();
                //不允许弹窗
                pss.StartInfo.CreateNoWindow = true;
                //弹窗需要隐藏
                pss.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
                pss.StartInfo.FileName = FlashPaperPath;
                pss.StartInfo.Arguments = string.Format("{0} {1} -o {2}", FlashPaperPath, WaitConvertFilePath, EndConvertFilePath);
                pss.StartInfo.UseShellExecute = false;
                pss.StartInfo.RedirectStandardInput = false;
                pss.StartInfo.RedirectStandardOutput = false;
                pss.Start();
                while (!pss.HasExited)
                {
                    continue;
                }
                //线程等待4s
                System.Threading.Thread.Sleep(5000);
                Success = true;
            }
            catch (Exception e)
            {
                Success = false;
            }
            return Success;
        }
    }
}